package com.apexedu.identity.entity;

import com.apexedu.biz.Const;
import com.apexedu.framework.util.ConfigUtil;
import com.apexedu.util.StringUtil;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * TSysMenu entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "T_SYS_MENU")
public class TSysMenu implements java.io.Serializable {

    /**
     * 希望类的不同版本对序列化兼容，只要确保类的不同版本具有相同的serialVersionUID
     */
    private static final long serialVersionUID = 1L;

    private String menuid;
    private String menuname;
    private String menupath;
    private String upmenuid;
    private Short depth;
    private String state;
    private Integer ordernum;
    private String sftjdmh;//是否提交到门户
    private String share2enterprise;// 是否允许企业管理员为本企业自定义角色权限时分配此菜单

    private long childMenuCount; // 该菜单的下级菜单的个数,非持久化
    private String belongtoapp; //业务系统编号
    private String oldbelongtoapp; //原业务系统编号 交院门户资源关联原业务系统用
    private String bizcode; //在业务系统中的编号
    private String upbizcode; //在业务系统中的父节点的编号
    private String srctype; // 资源类型

    private String isshare;     //是否共享资源

    private String ywxtmc;//业务系统名称 非持久化
    private List<TSysMenu> listButton = new ArrayList<TSysMenu>(); //菜单中的按钮
    private BigDecimal allordernum; //排序值，包含上级的排序值

    private String tb; //图标(用户服务组件展示)
    private String fwlb;//服务类别
    private String sftj; //是否推荐
    private Long djcs; //点击次数

    private String bgcolor;//背景色
    private String color;  //字体颜色
    //下级菜单集合
    private List<TSysMenu> listMenuSub = new ArrayList<TSysMenu>();
    private String dyid; //服务资源用户订阅id

    private String ismobile;//是否移动端

    private String fwsyfl;//门户服务所属分类

    private String appsftj;//是否是移动端推荐的应用 1,是，0否
    /**
     * 是否已订阅
     */
    private String sfydy;
    /**
     * 子菜单
     */
    private List<TSysMenu> childMenu = new ArrayList<TSysMenu>();
    /**
     * 接入系统url
     */
    private String appurl;

    private String des;//描述

    /**
     * 创建日期
     */
    private Date cjrq;

    /**
     * 浏览次数
     */
    private Integer djs;//描述

    private String py;//拼音

    private String  cjrqstr;

    private String unit;//办理单位(山东门户)
    private String workingtime;//办理时间(山东门户)
    private String workingplace;//办理地点(山东门户)
    private String contact;//联系电话(山东门户)
    private String rulesintroduced;//规则介绍（流程）(山东门户)
    private String fwtype;//服务列表(山东门户)
    private String version;//版本信息(山东门户)
    private String attention;//注意事项(山东门户)

    private String score;

    // Constructors

    /**
     * default constructor
     */
    public TSysMenu() {
    }

    /**
     * minimal constructor
     */
    public TSysMenu(String menuid) {
        this.menuid = menuid;
    }

    public TSysMenu(String menuid, List<TSysMenu> childMenu) {
        this.menuid = menuid;
        this.childMenu = childMenu;
    }

    /**
     * full constructor
     */
    public TSysMenu(String menuid, String menuname, String menupath, String upmenuid, Short depth, String state,
                    Integer ordernum, String share2enterprise) {
        this.menuid = menuid;
        this.menuname = menuname;
        this.menupath = menupath;
        this.upmenuid = upmenuid;
        this.depth = depth;
        this.state = state;
        this.ordernum = ordernum;
        this.share2enterprise = share2enterprise;
    }

    public TSysMenu(String menuid, String menuname, String menupath, String upmenuid, Short depth, String state,
                    Integer ordernum, String share2enterprise, String belongtoapp, long childMenuCount) {
        super();
        this.menuid = menuid;
        this.menuname = menuname;
        this.menupath = menupath;
        this.upmenuid = upmenuid;
        this.depth = depth;
        this.state = state;
        this.ordernum = ordernum;
        this.share2enterprise = share2enterprise;
        this.belongtoapp = belongtoapp;
        this.childMenuCount = childMenuCount;
    }

    // Property accessors
    @Id
    @Column(name = "MENUID", unique = true, nullable = false, length = 50)
    public String getMenuid() {
        return this.menuid;
    }

    public void setMenuid(String menuid) {
        this.menuid = menuid;
    }

    @Column(name = "MENUNAME")
    public String getMenuname() {
        return this.menuname;
    }

    public void setMenuname(String menuname) {
        this.menuname = menuname;
    }

    @Column(name = "MENUPATH", length = 400)
    public String getMenupath() {
        return this.menupath;
    }

    public void setMenupath(String menupath) {
        this.menupath = menupath;
    }

    @Column(name = "UPMENUID", length = 50)
    public String getUpmenuid() {
        if (upmenuid == null && menuid != null) {
            upmenuid = menuid.substring(0, menuid.length() - 3);
        }
        return this.upmenuid;
    }

    public void setUpmenuid(String upmenuid) {
        this.upmenuid = upmenuid;
    }

    @Column(name = "DEPTH", precision = 2, scale = 0)
    public Short getDepth() {
        return this.depth;
    }

    public void setDepth(Short depth) {
        this.depth = depth;
    }

    @Column(name = "STATE", length = 3)
    public String getState() {
        return this.state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Column(name = "ORDERNUM", precision = 6, scale = 0)
    public Integer getOrdernum() {
        return this.ordernum;
    }

    public void setOrdernum(Integer ordernum) {
        this.ordernum = ordernum;
    }

    @Column(name = "SHARE2ENTERPRISE", length = 2)
    public String getShare2enterprise() {
        return this.share2enterprise;
    }

    public void setShare2enterprise(String share2enterprise) {
        this.share2enterprise = share2enterprise;
    }

    @Transient
    public long getChildMenuCount() {
        return childMenuCount;
    }

    public void setChildMenuCount(long childMenuCount) {
        this.childMenuCount = childMenuCount;
    }

    @Column(name = "BIZCODE")
    public String getBizcode() {
        if (bizcode == null) {
            bizcode = menuid;// 在权限中心中添加的资源，其业务编号bizcode，就是menuid
        }
        return bizcode;
    }

    public void setBizcode(String bizcode) {
        this.bizcode = bizcode;
    }

    @Column(name = "UPBIZCODE")
    public String getUpbizcode() {
        if (upbizcode == null) {
            upbizcode = upmenuid;// 在权限中心中添加的资源，其资源编号bizcode，就是menuid
        }
        return upbizcode;
    }

    public void setUpbizcode(String upbizcode) {
        this.upbizcode = upbizcode;
    }

    @Column(name = "BELONGTOAPP")
    public String getBelongtoapp() {
        return belongtoapp;
    }

    public void setBelongtoapp(String belongtoapp) {
        this.belongtoapp = belongtoapp;
    }

    @Column(name = "SRCTYPE")
    public String getSrctype() {
        return srctype;
    }

    public void setSrctype(String srctype) {
        this.srctype = srctype;
    }

    public String getIsshare() {
        return isshare;
    }

    public void setIsshare(String isshare) {
        this.isshare = isshare;
    }

    @Column(name = "SFTJDMH")
    public String getSftjdmh() {
        return sftjdmh;
    }

    public void setSftjdmh(String sftjdmh) {
        this.sftjdmh = sftjdmh;
    }

    @Transient
    public List<TSysMenu> getListButton() {
        return listButton;
    }

    public void setListButton(List<TSysMenu> listButton) {
        this.listButton = listButton;
    }

    @Transient
    public BigDecimal getAllordernum() {
        return allordernum;
    }

    public void setAllordernum(BigDecimal allordernum) {
        this.allordernum = allordernum;
    }

    @Transient
    public String getYwxtmc() {
        return ywxtmc;
    }

    public void setYwxtmc(String ywxtmc) {
        this.ywxtmc = ywxtmc;
    }

    @Column(name = "TB")
    public String getTb() {
        return tb;
    }

    public void setTb(String tb) {
        this.tb = tb;
    }

    @Column(name = "FWLB")
    public String getFwlb() {
        return fwlb;
    }

    public void setFwlb(String fwlb) {
        this.fwlb = fwlb;
    }

    @Column(name = "SFTJ")
    public String getSftj() {
        return sftj;
    }

    public void setSftj(String sftj) {
        this.sftj = sftj;
    }

    @Column(name = "DJCS")
    public Long getDjcs() {
        return djcs == null ? 0l : djcs;
    }

    public void setDjcs(Long djcs) {
        this.djcs = djcs;
    }


    @Column(name = "COLOR")
    public String getColor() {
        return StringUtil.isBlank(color) ? "white" : color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Column(name = "BGCOLOR")
    public String getBgcolor() {
        return StringUtil.isBlank(bgcolor) ? "blue" : bgcolor;
    }

    public void setBgcolor(String bgcolor) {
        this.bgcolor = bgcolor;
    }

    @Transient
    public List<TSysMenu> getListMenuSub() {
        return listMenuSub;
    }

    public void setListMenuSub(List<TSysMenu> listMenuSub) {
        this.listMenuSub = listMenuSub;
    }

    @Transient
    public String getDyid() {
        return dyid;
    }

    public void setDyid(String dyid) {
        this.dyid = dyid;
    }

    @Column(name = "ISMOBILE")
    public String getIsmobile() {
        return StringUtil.isBlank(ismobile) ? "0" : ismobile;
    }

    public void setIsmobile(String ismobile) {
        this.ismobile = ismobile;
    }


    @Transient
    public String getFwsyfl() {
        return fwsyfl;
    }

    public void setFwsyfl(String fwsyfl) {
        this.fwsyfl = fwsyfl;
    }

    @Column(name = "APPSFTJ")
    public String getAppsftj() {
        return appsftj;
    }

    public void setAppsftj(String appsftj) {
        this.appsftj = appsftj;
    }

    @Column(name = "OLDBELONGTOAPP")
    public String getOldbelongtoapp() {
        return oldbelongtoapp;
    }

    public void setOldbelongtoapp(String oldbelongtoapp) {
        this.oldbelongtoapp = oldbelongtoapp;
    }

    @Transient
    public String getSfydy() {
        return sfydy;
    }

    public void setSfydy(String sfydy) {
        this.sfydy = sfydy;
    }

    @Transient
    public List<TSysMenu> getChildMenu() {
        return childMenu;
    }

    public void setChildMenu(List<TSysMenu> childMenu) {
        this.childMenu = childMenu;
    }

    @Transient
    public String getAppurl() {
        return appurl;
    }

    public void setAppurl(String appurl) {
        this.appurl = appurl;
    }

    @Column(name = "DES")
    public String getDes() {
        return des;
    }

    public void setDes(String des) {
        this.des = des;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "CJRQ", length = 7)
    public Date getCjrq() {
        return this.cjrq;
    }

    public void setCjrq(Date cjrq) {
        this.cjrq = cjrq;
    }

    @Column(name = "DJS", precision = 8, scale = 0)
    public Integer getDjs() {
        return this.djs;
    }

    public void setDjs(Integer djs) {
        this.djs = djs;
    }

    /**
     * 是否门户资源、资源分类
     *
     * @return
     */
    @Transient
    public boolean isPortal() {
        return ConfigUtil.getString("portalCode").equals(this.belongtoapp);
    }

    /**
     * 是否角色权限中心资源
     *
     * @return
     */
    @Transient
    public boolean isAuc() {
        return ConfigUtil.getString("AuCenterAccessEnterCode").equals(this.belongtoapp);
    }

    /**
     * 是否角色权限中心菜单
     *
     * @return
     */
    @Transient
    public boolean isAucMenu() {
        return ConfigUtil.getString("AuCenterAccessEnterCode").equals(this.belongtoapp) && this.menuid.length() == Const.PortalMenuLength.MENU;
    }

    /**
     * 是否门户资源分类
     *
     * @return
     */
    @Transient
    public boolean isPortalMenuType() {
        return ConfigUtil.getString("portalCode").equals(this.belongtoapp) && this.menuid.length() == Const.PortalMenuLength.MENU_TYPE;
    }

    /**
     * 是否门户资源
     *
     * @return
     */
    @Transient
    public boolean isPortalMenu() {
        return ConfigUtil.getString("portalCode").equals(this.belongtoapp) && this.menuid.length() == Const.PortalMenuLength.MENU;
    }


    @Transient
    public String getPy() {
        return this.py;
    }

    public void setPy(String py) {
        this.py = py;
    }

    @Transient
    public String getCjrqstr() {
        return this.cjrqstr;
    }

    public void setCjrqstr(String cjrqstr) {
        this.cjrqstr = cjrqstr;
    }

    @Transient
    public String getUnit() {
        return this.unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    @Transient
    public String getWorkingtime() {
        return this.workingtime;
    }

    public void setWorkingtime(String workingtime) {
        this.workingtime = workingtime;
    }

    @Transient
    public String getWorkingplace() {
        return this.workingplace;
    }

    public void setWorkingplace(String workingplace) {
        this.workingplace = workingplace;
    }

    @Transient
    public String getContact() {
        return this.contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    @Transient
    public String getRulesintroduced() {
        return this.rulesintroduced;
    }

    public void setRulesintroduced(String rulesintroduced) {
        this.rulesintroduced = rulesintroduced;
    }

    @Transient
    public String getFwtype() {
        return this.fwtype;
    }

    public void setFwtype(String fwtype) {
        this.fwtype = fwtype;
    }

    @Transient
    public String getVersion() {
        return this.version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @Transient
    public String getAttention() {
        return this.attention;
    }

    public void setAttention(String attention) {
        this.attention = attention;
    }

    @Transient
    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }
}
